<?php
require_once('libs/Zend/Soap/AutoDiscover.php');
require_once('libs/Zend/Soap/Server.php');
require_once('libs/Zend/Soap/Wsdl.php');

class api extends MX_Controller
{
    public function __construct()
    {
        parent::__construct();
    }
    
    public function soap()
    {
        $options = array(
            'wsdl_cache' => '0');
        $urlOptions = array(
            'controller' => 'api' , 
            'action' => 'wsdl');
        $url = site_url('api/wsdl');
        $server = new Zend_Soap_Server($url, $options);
        // set SOAP service class      
        $server->setClass('testservice_model');
        // register exceptions that generate SOAP faults
        //$faults = array(
        //    'SMCore_Soap_Exception');
        //$server->registerFaultException($faults);
        // handle request
        $server->handle();
    }
    
    public function wsdl()
    {
        $wsdl = new Zend_Soap_AutoDiscover();
        // attach SOAP service class
        $wsdl->setClass('testservice_model');
        // set SOAP action URI
        $options = array(
            'controller' => 'api' , 
            'action' => 'soap');
	   $url = site_url('api/wsdl');
        $wsdl->setUri($url);
        // handle request 
        $wsdl->handle();
    }
}